<?php
/**
 *@file commentauthinfo.php
*@author yuebin
*@date 2015-7-31
*@brief
*/
namespace haibao\comment\business;

use haibao\comment\data\CommentAuthInfo as CommentAutoInfoData;
use haibao\comment\model\data\CommentType as CommentTypeModel;
class CommentAuthInfo extends \haibao\cms\business\Base{
  
	public static function getAutoInfoByUserId($userId){
		
		if(!isset($userId)) return;
		
		$data  = new CommentAutoInfoData();
		return $data->getAutoInfoByUserId($userId);
		
	}
	
	public static function packageContent($type,$objectId,$content){
	
		$pushContent = $fullTextUrl = '';
		switch ($type){
			case CommentTypeModel::TYPE_CODE_ARTICLE:
				$data = new \haibao\cms\data\Article();
				$articleInfo = $data->getOneById($objectId);
				$pushContent = $content.'【@海报时尚网 】'.$articleInfo->Title." 全文→ ".\haibao\classlibrary\comment\Config::getConfig(\haibao\classlibrary\comment\Config::CLASSLIBRARY_CONFIG_HAIBAO_URL).'/article/'.$articleInfo->PublishId.'.html';
				break;
			case CommentTypeModel::TYPE_CODE_PIC:
				$data = new \haibao\cms\data\imagecollective\ImageCollective();
				$picInfo = $data->getOneById($objectId);
				$pushContent = $content.'【@海报时尚网 】'.$picInfo->Title." 全文→ ".\haibao\classlibrary\comment\Config::getConfig(\haibao\classlibrary\comment\Config::CLASSLIBRARY_CONFIG_HOST_PIC).'/pics/'.$picInfo->Id.'.htm';
				break;
			case CommentTypeModel::TYPE_CODE_VIDEO:
				$data = new \haibao\cms\data\Video();
				$videoInfo = $data->getOneById($objectId);
				$pushContent = $content.'【@海报时尚网 】'.$videoInfo->Title." 全文→ ".\haibao\classlibrary\comment\Config::getConfig(\haibao\classlibrary\comment\Config::CLASSLIBRARY_CONFIG_HOST_EXCLUSIVE).'/play/'.$videoInfo->Id.'.htm';
				break;
			case CommentTypeModel::TYPE_CODE_FEATURE:
				$data = new \haibao\cms\data\FeaturePublish();
				$featureInfo = \haibao\cms\business\FeaturePublish::getFeatureById($objectId);
				$pushContent = $content.'【@海报时尚网 】'.$featureInfo->FeatureDefine->FeatureName." 全文→ ".$featureInfo->Url;
				break;
			default :
				break;
		}
	
		$pushContent = preg_replace('/<img.*src="(.*)".*?>/i', "$1", $pushContent);
		return $pushContent;
	
	}
	
	public static function getAuthInfo($userId){
		if(!$userId){
			throw new BusinessException('用户ID为空',self::DATA_EMPTY);
		}
		$authInfoData = new \haibao\comment\data\CommentAuthInfo();
		return $authInfoData->getAuthInfo($userId);
	}
	
	public static function saveAuthInfo($model){
		$authInfoData = new \haibao\comment\data\CommentAuthInfo();
		$authInfoData->add($model);
	}
	
	public static function updateAuthDataByUserId($userId,$arrSet){
		$authInfoData = new \haibao\comment\data\CommentAuthInfo();
		$authInfoData->updateAuthDataByUserId($userId,$arrSet);
	}
	
}